package request

type CategoryAddRequest struct {
	Name  string `form:"name" json:"name" binding:"required"`
	Icon  string `form:"icon" json:"icon" binding:"required"`
	Image string `form:"image" json:"image" `
	Desc  string `form:"desc" json:"desc" `
	Sort  int    `form:"sort" json:"sort" `
	// Status int    `form:"status" json:"status" `
}

func (categoryAddRequest CategoryAddRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"name.required": "分类名称不能为空",
		"icon.required": "分类图标不能为空",
	}
}

type CategoryUpdateRequest struct {
	Id     int    `form:"id" json:"id" binding:"required"`
	Name   string `form:"name" json:"name" binding:"required"`
	Icon   string `form:"icon" json:"icon" binding:"required"`
	Image  string `form:"image" json:"image" binding:"required"`
	Desc   string `form:"desc" json:"desc" binding:"required"`
	Sort   *int   `form:"sort" json:"sort" binding:"required"`
	Status *int   `form:"status" json:"status" binding:"required"`
}

func (categoryUpdateRequest CategoryUpdateRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required":   "分类ID不能为空",
		"name.required": "分类名称不能为空",
		"icon.required": "分类图标不能为空",
	}
}

type CategoryDeleteRequest struct {
	Id uint `form:"id" json:"id" binding:"required"`
}

func (categoryDeleteRequest CategoryDeleteRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required": "分类ID不能为空",
	}
}

type CategoryPageListRequest struct {
	Name     string `json:"name" form:"name"`     // 分类名称
	Status   *int   `json:"status" form:"status"` // 状态
	Page     int    `json:"page" form:"page" binding:"required,gte=1"`
	PageSize int    `json:"page_size" form:"page_size" binding:"required,gte=1,lte=100"`
}

func (categoryPageListRequest CategoryPageListRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"page.required":      "页码不能为空",
		"page.gte":           "页码不能小于1",
		"page_size.required": "每页条数不能为空",
		"page_size.gte":      "每页条数不能小于1",
		"page_size.lte":      "每页条数不能大于100",
	}
}
